home *** CD-ROM | disk | FTP | other *** search
- /* strings.c */
-
- #include <stdio.h>
- #define DESMET
-
- /* #define DEBUG */
-
- static char ver[] = "DeSmet C";
-
- #define LIMIT 3
- #define MAXLINE 200
-
- int num_printable = 0;
- char line[MAXLINE + 10]; /* ten extra for slop jht */
-
- main(argc,argv)
- int argc;
- char *argv[];
- {
- FILE *input;
- int c;
-
- if (argc < 2) {
- puts("Usage: strings filename\n");
- exit(1);
- }
-
- if ((input = fopen(argv[1],"rb")) == NULL) {
- puts("Can't open "); puts(argv[1]);
- exit(1);
- }
-
- while ((c = getc(input)) != EOF) {
- if (num_printable < MAXLINE && (c >= ' ' && c <= '~') || c == '\n' || c == '\r' || c == '\t')
- line[num_printable++] = c;
- else {
- if (num_printable > LIMIT) {
-
- #ifdef DEBUG
- printd(num_printable);
- puts(" chars :");
- #endif
-
- line[num_printable] = '\0';
- puts(line);
- #ifdef DESMET
- putchar('\n');
- #endif
- }
- num_printable = 0;
- } /* else */
- } /* while */
-
- if (num_printable > LIMIT) {
- line[num_printable] = '\0';
- puts(line);
- #ifdef DESMET
- putchar('\n');
- #endif
- }
- } /* main */
-
- #ifdef DEBUG
-
- printd(n) /* print n in decimal (recursive) */
- int n;
- {
- int i;
-
- if ((i = n / 10) != 0)
- printd(i);
- putchar(n % 10 + '0');
- }
-
- #endif
-